package api

import (
	goods "api-gateway/basic/goods_proto"
	"api-gateway/basic/inits"
	"api-gateway/handler/request"
	"api-gateway/handler/response"
	"github.com/gin-gonic/gin"
)

// HotSearchList
// @Summary      热度搜索列表
// @Description  热度搜索列表
// @Tags         首页模块
// @Accept       json
// @Produce      json
// @Param        HotSearch  query      request.Hot  true  "首页参数"
// @Success      200  {object}  response.Response
// @Failure      400   {object}  response.Response
// @Router       /HotSearch/hotSearchList [get]
func HotSearchList(c *gin.Context) {
	var v request.Hot
	if err := c.ShouldBind(&v); err != nil {
		response.Error(c, 400, "参数错误", err.Error())
		return
	}
	TopHot, err := inits.GoodsClient.HotSearchList(c, &goods.HotSearchListReq{
		Limit: v.Limit,
	})
	if err != nil {
		response.Error(c, 500, "查询失败", err.Error())
		return
	}
	response.Error(c, 200, "查询成功", TopHot)
}

// HotSearchGoodsList
// @Summary      热度搜索商品列表
// @Description  热度搜索商品列表
// @Tags         首页模块
// @Accept       json
// @Produce      json
// @Param        HotSearch  query      request.WelcomeSearch  true  "首页参数"
// @Success      200  {object}  response.Response
// @Failure      400   {object}  response.Response
// @Router       /HotSearch/hotSearchGoodsList [get]
func HotSearchGoodsList(c *gin.Context) {
	var v request.WelcomeSearch
	if err := c.ShouldBind(&v); err != nil {
		response.Error(c, 400, "参数错误", err.Error())
		return
	}
	TopHot, err := inits.GoodsClient.HotSearchGoods(c, &goods.HotSearchGoodsReq{
		ReqBrandName: v.BrandName,
	})
	if err != nil {
		response.Error(c, 500, "查询失败", err.Error())
		return
	}
	response.Error(c, 200, "查询成功", TopHot)
}
